package cn.lizemin.demo.thread.lambda;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Comparator;

/**
 * @author: lizemin
 * @version: 1.0
 */
public class Lambda2 {
    //这是一个main方法,是程序的入口
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("adada");
        list.add("aaaddfada");
        list.add("aadasdafsdfa");
        list.add("a");
        list.add("aadfa");
        System.out.println(list);

        list.sort(getComparator());
        System.out.println("-----------------------");
        System.out.println(list);


    }

    private static Comparator<String> getComparator() {
        /*Comparator<String> comparator = new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 0;
            }

        };*/


        return (s1,s2) -> s1.length() - s2.length();
    }
}
